import { addTask } from "@/redux/tasks/tasksSlice";
import { NewTask } from "."
import { useAppDispatch } from "@/hook/useRedux";
import { useState } from "react";

interface Props {
  columnId: string
  setOpen(bool: boolean): void
  name: string
}

export const NewTaskCard = ({ columnId, setOpen, name }: Props) => {
  const dispatch = useAppDispatch()
  const [sendBtn, setSendBtn] = useState(false)

  const postTask = (other: any) => {
    dispatch(addTask({ columnId, other })).then(() => {
      setOpen(false)
      setSendBtn(false)
    })
  }

  return <NewTask setSendBtn={setSendBtn} sendBtn={sendBtn} postTask={postTask} setOpen={setOpen} name={name} />
}